<?php

namespace App\Api\Logic;

use App\Api\Logic\Validate\GoodsValidate;
use App\Exceptions\ValidationException;
use App\Helpers\ResponseEnum;

class GoodsLogic extends BaseLogic
{
    /**
     * @return GoodsValidate
     */
    private function getValidate():GoodsValidate{
        return  new GoodsValidate();
    }

    /**
     * 获取商品列表
     * @param $params
     * @return void
     * @throws ValidationException
     */
    public function getGoodsList($params){
        $validate = $this->getValidate();
        if(!$validate->scene('getGoodsList')->check($params)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }

    /**
     * @param array $param
     * @return void
     */
    public function getGoodsInfo(array $param)
    {
        $validate = $this->getValidate();
        if(!$validate->scene('getGoodsInfo')->check($param)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }
}
